<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>管理员登录</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/antd/dist/antd.min.css" />
</head>
<body>
  <div id="root" style="max-width:400px;margin:80px auto;"></div>
  <script src="https://cdn.jsdelivr.net/npm/react@18/umd/react.development.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/react-dom@18/umd/react-dom.development.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/antd/dist/antd.min.js"></script>
  <script>
    const { useState } = React;
    function Login() {
      const [username, setUsername] = useState("");
      const [password, setPassword] = useState("");
      const [loading, setLoading] = useState(false);
      const onLogin = () => {
        setLoading(true);
        fetch("/admin/auth/login", {
          method: "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify({ username, password })
        }).then(r => r.json()).then(res => {
          setLoading(false);
          if (res.message === "登录成功") {
            window.location.href = "/admin/index.html";
          } else {
            antd.message.error(res.message || "登录失败");
          }
        });
      };
      return React.createElement("div", {},
        React.createElement("h2", { style: { textAlign: "center" } }, "管理员登录"),
        React.createElement(antd.Input, {
          placeholder: "用户名",
          value: username,
          onChange: e => setUsername(e.target.value),
          style: { marginBottom: 12 }
        }),
        React.createElement(antd.Input.Password, {
          placeholder: "密码",
          value: password,
          onChange: e => setPassword(e.target.value),
          style: { marginBottom: 12 }
        }),
        React.createElement(antd.Button, {
          type: "primary",
          block: true,
          loading,
          onClick: onLogin
        }, "登录")
      );
    }
    ReactDOM.createRoot(document.getElementById("root")).render(React.createElement(Login));
  </script>
</body>
</html> 